﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.Unity;

namespace perfume.Models.DB
{
    /*public interface IProduct_repository
    {
        IQueryable<category> GetCategory();
        IQueryable<product> GetProductByCat(string CatId);

        //con thiu acccount
    }*/

    public class Product_repository
    {
        perfume_dbEntities per_db = new perfume_dbEntities();
        public IQueryable<category> GetCategory()
        {
            return per_db.categories;
            
        }

        public IQueryable<product> GetProductByCat(int Cat)
        {
            return per_db.products.Where(p => p.category_id == Cat);
        }

        public IQueryable<product> GetProductByName(string search)
        {
            //return per_db.products.Where(p => p.product_name.StartsWith(search));
            return per_db.products.Where(p => p.product_name.Contains(search));
        }
    }


}